import apis from "../../http/apis"

export default {
    namespaced: true,
    state: {
        salesmans: {
            account: '',
            password: ''
        },
        _id:''
    },
    actions: {
        //管理员登录
        async salesmansLogin(context) {
            const { data } = await apis.salesmans.salesmansLogin({
                ...context.state.salesmans
            })
            console.log(data);
            if (data.status) {
                alert(data.message)
                localStorage.token = data.token
                localStorage.salesmansId = data.data[0]._id
                location.hash = '#/salesmansSystem'
                context.commit('changeId',data.data[0]._id);
            } else {
                alert(data.message)
            }
        }
    },
    mutations:{
        changeId(state,data){
            state._id=data
        }
    }
    
}